package com.the_last.controller;

import com.the_last.pojo.po.SysPermissionBusinessType;
import com.the_last.service.ISysPermissionBusinessTypeService;
import com.the_last.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 权限业务类型控制器
 */
@RestController
@RequestMapping("/permission-business-type")
@RequiredArgsConstructor
public class SysPermissionBusinessTypeController {
    
    private final ISysPermissionBusinessTypeService permissionBusinessTypeService;
    
    /**
     * 获取所有权限业务类型列表
     * @return 权限业务类型列表
     */
    @GetMapping("/list")
    @PreAuthorize("hasAuthority('PERMISSION_QUERY')")
    public Result<List<SysPermissionBusinessType>> getPermissionBusinessTypeList() {
        return permissionBusinessTypeService.getAllPermissionBusinessTypes();
    }
    
    /**
     * 根据ID获取权限业务类型
     * @param id 业务类型ID
     * @return 权限业务类型详情
     */
    @GetMapping("/{id}")
    @PreAuthorize("hasAuthority('PERMISSION_QUERY')")
    public Result<SysPermissionBusinessType> getPermissionBusinessTypeById(@PathVariable Long id) {
        return permissionBusinessTypeService.getPermissionBusinessTypeById(id);
    }
}